<?php 

	function getHTML($url, $post, $cookies){
		$proxy_ip = $ip; //proxy IP here
		$proxy_port = 80; //proxy port from your proxy list
		$ch = @curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_HEADER, true);
		curl_setopt($ch, CURLINFO_HEADER_OUT, true);
		curl_setopt($ch, CURLOPT_COOKIEJAR, "cookieFile");
		curl_setopt($ch, CURLOPT_VERBOSE, 1);
			if ($cookies) curl_setopt($ch, CURLOPT_COOKIE, $cookies);
		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1');
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
			if ($post){
				curl_setopt($ch, CURLOPT_POST, 1);
				curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 
			}
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true); 
		curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, true);
		curl_setopt($ch, CURLOPT_TIMEOUT, 30); 
		curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 30);
		$page = curl_exec( $ch);
		curl_close($ch); 
		return $page;		
	}
	
	function getHTMLCookie($url, $post, $cookies){
		$proxy_ip = $ip; //proxy IP here
		$proxy_port = 80; //proxy port from your proxy list
		$ch = @curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_HEADER, true);
		curl_setopt($ch, CURLINFO_HEADER_OUT, true);
		curl_setopt($ch, CURLOPT_COOKIEJAR, "cookieFile");
		curl_setopt($ch, CURLOPT_VERBOSE, 1);
			if ($cookies) curl_setopt($ch, CURLOPT_COOKIE, $cookies);
		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1');
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
			if ($post){
				curl_setopt($ch, CURLOPT_POST, 1);
				curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 
			}
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true); 
		curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, true);
		curl_setopt($ch, CURLOPT_TIMEOUT, 30); 
		curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 30);
		$page = curl_exec( $ch);
		$galleta=curl_getinfo($ch);
		curl_close($ch); 
		return $galleta;		
	}
		
	function mvToken($html){
		$tmp=explode('.video=',$html);
		$tmp=explode('&',$tmp[1]);
		return $tmp[0];	
	}
	
	function gralToken($html, $start , $end){
		$tmp=explode($start,$html);
		$tmp=explode($end,$tmp[1]);
		return $tmp[0];	
	}
	
	function guToken($html){
		$temp0=explode('background:#f9f9f9;border:1px dotted #bbb;padding:7px;',$html);
		$temp0=explode('href="',$temp0[1]);
		$temp0=explode('"',$temp0[1]);
		return $temp0[0];
	}
	
	function createPost($campos,$html){
		$data='';
			for($i=0;$i<sizeof($campos);$i++){
				if($i==(sizeof($campos)-1)){
					$data=$data.$campos[$i].'='.getValue($html,$campos[$i]);
				}else{
					$data=$data.$campos[$i].'='.getValue($html,$campos[$i]).'&';
				}
			}
		return $data;
	}
	
	function getValue($html, $campo){
		$temp=explode('name="'.$campo.'" value="',$html);
		$temp1=explode('"',$temp[1]);
		return $temp1[0];
	}
	
	function Estatus($url){
		 	$ch = curl_init();
			curl_setopt($ch, CURLOPT_URL,            $url);
			curl_setopt($ch, CURLOPT_HEADER,         1);
			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($ch, CURLOPT_TIMEOUT,        30);
			$info = curl_getinfo($ch);
			curl_close($ch);
			return $info['http_code'];
	}
	
	function getCookie($html,$name){
		$parte=gralToken($html,'Set-Cookie: '.$name.'=',';');
		return $name.'='.$parte;
	}
	
	function escape($cadena_entrada){ 
		$cadena_salida=""; 
		$longitud=strlen($cadena_entrada); 
		for($cuenta=0; $cuenta<$longitud; $cuenta++){ 
			$cadena_salida.="%".dechex(ord(substr($cadena_entrada,$cuenta,1))); 
		}	
		return $cadena_salida; 
	} 
	
	

?>